package servlet;

import includes.Html;
import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;


/**
 * Servlet implementation class Contact
 */
public class Contact extends HttpServlet {
	private static final long serialVersionUID = 1L;
	private Html htmlInclude = new Html();
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public Contact() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		PrintWriter out = response.getWriter();
		RequestDispatcher rd = request.getRequestDispatcher ("main_links.jsp");
		HttpSession currentSession = request.getSession();
		
		out.println(htmlInclude.setHeader("Contact Us"));
		out.println("<div id ='header'></div>");
		out.println("<div id='nav-container'>");
		out.println("<div id='top-links'>");
	    rd.include (request, response);
	    
	    out.println("<div id='login'>");
	    String myname =  (String)currentSession.getAttribute("username");

	    if(myname!=null)
	    {
	    	out.println("<p class='blue'>[ You're logged in as " + myname + " - <a href='Logout'>logout?</a> ]</p>");
	    }
	    else
	    {
	    	out.println("<p class='blue'>[ You're not logged in ]</p>");
	    }
	    out.println("</div>");
	    
	    out.println("</div></div><div id ='content'>");
	    out.println("<div id='content-left-contact'");
	    out.println("<img src='images/contact.png' /><p>Write to us on the following address : ");
	    out.println("<a href='mailto:tlrs-info@fantasia.com'>tlrs-info@fantasia.com</a></p><br/>");
	    out.println("</div>");
	    out.println("<div id='lower-content'>");
	    out.println("<table class='contact'>");
	    out.println("<form action='ContactSendMail' method='post'>");
	    out.println("<tr><td>... or fill out the online form!</td><td></td></tr>");
	    out.println("<tr><td>Dit navn</td><td><input type='text' name='name' value=''/></td></tr>");
	    out.println("<tr><td>Din Email</td><td><input type='text' name='email' value=''/></td></tr>");
	    out.println("<tr><td>Besked</td><td><textarea name='message' rows='8'></textarea></td></tr>");
	    out.println("<tr><td></td><td align='right'><input class='submit' type='submit' value='send' /></td></tr>");
	    out.println("</form>");
	    out.println("</table>");
	    out.println("</div></div>");
		out.println(htmlInclude.setFooter());
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

}
